package com.example.demo.service;

import com.example.demo.dao.PermissionDao;
import com.example.demo.dao.RoleDao;
import com.example.demo.dao.UserDao;
import com.example.demo.entity.Permission;
import com.example.demo.entity.Role;
import com.example.demo.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Security 数据服务
 *
 * @author
 */
@Service
public class SecurityDataService {
    @Autowired
    private UserDao sUserDao;
    @Autowired
    private RoleDao sRoleDao;
    @Autowired
    private PermissionDao sPermissionDao;

    public User findSUserByName(String username) {
        return sUserDao.findUserByName(username);
    }

    public List<Role> findSRoleListBySUserId(int sUserId) {
        return sRoleDao.findSRoleListBySUserId(sUserId);
    }

    public List<Role> findSRoleListBySPermissionUrl(String sPermissionUrl) {
        return sRoleDao.findSRoleListBySPermissionUrl(sPermissionUrl);
    }

    public List<Permission> findSPermissionListBySUserId(int sUserId) {
        return sPermissionDao.findSPermissionListBySUserId(sUserId);
    }

    public List<Permission> findSPermissionListBySPermissionUrl(String sPermissionUrl) {
        return sPermissionDao.findSPermissionListBySPermissionUrl(sPermissionUrl);
    }
}
